/**
 * Copyright 2015-2016 eyaomall.cn
 * All rights reserved.
 *
 * @project
 * @author jackey
 * @version 1.0
 * @date 2016-01-06
 */
package com.eyaomall.wxmall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.eyaomall.wxmall.common.helper.MemberHelper;
import com.eyaomall.wxmall.dao.GoodsDao;
import com.eyaomall.wxmall.model.po.Goods;
import com.eyaomall.wxmall.model.vo.GoodsVO;
import com.eyaomall.wxmall.service.GoodsService;
import com.lycheeframework.core.cmp.kit.PageHTTPObject;
import com.lycheeframework.core.cmp.kit.Pages;

/**
 * 商品服务
 * 
 * @author yuhuafeng
 * @date 2016-9-7
 */
@Service
public class GoodsServiceImpl implements GoodsService {

	@Autowired
	private GoodsDao goodsDao;

	/**
	 * 根据ID查询产品信息
	 */
	public Goods queryByGoodsId(Integer id) {

		return goodsDao.queryById(id);
	}

	/**
	 * 根据ids查询我的产品信息
	 * 
	 * @param ids
	 * @return
	 */
	public List<Goods> list(String ids) {

		return goodsDao.list(ids);
	}

	/**
	 * 根据ShopId查询主页产品信息
	 * 
	 * @param ids
	 * @return
	 */
	public List<Goods> hotGoods() {

		Goods goods = new Goods();
		goods.setShopId(MemberHelper.getShopId());
		return goodsDao.hotGoods(goods);
	}

	/**
	 * 分页显示产品列表
	 */
	public Pages<?> page(GoodsVO goodsVO, PageHTTPObject object) {
		return goodsDao.page(goodsVO, object);
	}

	/**
	 * 查询产品信息
	 */
	public Goods query(Integer id) {
		return goodsDao.query(id);
	}

	/**
	 * 修改我的产品库存
	 * 
	 * @param goods
	 * @return
	 */
	public boolean updateInventory(Goods goods) {

		return goodsDao.updateInventory(goods);
	}

	/**
	 * 修改我的产品信息
	 * 
	 * @param goods
	 * @return
	 */
	public boolean update(Goods goods) {

		return goodsDao.update(goods) > 0 ? true : false;
	}

	/**
	 * 热卖商品列表
	 */
	public Pages<?> hotGoods(Goods goods, PageHTTPObject httpObject) {
		Goods goos = new Goods();
		goos.setShopId(MemberHelper.getShopId());
		return (Pages<?>) goodsDao.hotGoods(goos, httpObject);
	}
}
